$(function(){
	initPage();
});

function initPage(){
	$('#custId').combotree({
		editable:false,
		disabled:false,
	    url:rootPath+'/register/custlist/get',
	    onSelect:function(node){
	    	if(node.parentId){
	    		$.messager.alert(i18n.dialog.AlertTitle,"只能选择最顶层客户导出报表");
	    		$('#custId').combotree('clear');
	    		return false;
	    	}
	    }
	});
}

//导出事件报表
function exportReport(){
	//获取导出条件
	var expParam = {};
	//客户ID
	expParam.expCustId = $('#custId').combotree('getValue');
	if(!expParam.expCustId){
		$.messager.alert(i18n.dialog.AlertTitle,i18n.stat.CustEmpty);
		return;
	}
	//日期范围
	expParam.expStartDate = $('#statStartDate').val().replace(/年|月/g,'');
	expParam.expEndDate = $('#statEndDate').val().replace(/年|月/g,'');
	if(!expParam.expStartDate||!expParam.expEndDate){
		$.messager.alert(i18n.dialog.AlertTitle,i18n.stat.ExportDateEmpty);
		return;
	}
	//构建导出URL地址
	var expURL = rootPath + "/stat/report/exportTicketAnalysisReport?a=1";
	for(var p in expParam){
		expURL += "&"+p+"="+expParam[p];
	}
	$("#exportIframe").attr("src",expURL);
}

//导出重置
function exportReset(){
	//责任顾问Id
	$('#custId').combobox('setValue','');
}